<template>
  <div style="display: flex;">
    <div :style="{width:(isCollapse ? '64px' : '168px')}">
      <el-menu
          background-color="#222839"
          style="width:100%;height:100vh;"
          text-color="#fff"
          active-text-color="#00aa88"
          unique-opened
          router
          :collapse="isCollapse"
          :collapse-transition="false"
      >
        <!-- 左侧菜单栏顶部条  -->
        <el-row style="padding-top: 10px;">
          <el-col :span="6"></el-col>
          <el-col :span="12" style="padding-left: 7px;">
            <el-avatar src="/img/img.png" :style="{width:(isCollapse ? '30px' : '50px'),height:(isCollapse ? '30px' : '50px')}"></el-avatar>
          </el-col>
          <el-col :span="6"></el-col>
        </el-row>
        <el-row style="padding:25px">
            <span style="color:#fff;font-weight:bold;position:relative;top:8px;left:2px;text-align: center">
              工地管理系统
            </span>
        </el-row>
        <el-sub-menu index="1">
          <template #title>
            <el-icon style="font-size:21px;">
              <Checked/>
            </el-icon>
            <span>质量管理</span>
          </template>
          <el-menu-item index="qualityManagement">检查单管理</el-menu-item>
          <el-menu-item index="/qualityAccept">验收管理</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="2">
          <template #title>
            <el-icon style="font-size:21px;">
              <View/>
            </el-icon>
            <span>验收管理</span>
          </template>
          <el-menu-item index="/acceptanceManagement">验收列表</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="3">
          <template #title>
            <el-icon style="font-size:21px;">
              <Box/>
            </el-icon>
            <span>试验管理</span>
          </template>
          <el-menu-item index="/experimentEquipment">仪器管理</el-menu-item>
          <el-menu-item index="/experimentLedger">台账管理</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="5">
          <template #title>
            <el-icon style="font-size:21px;">
              <MessageBox/>
            </el-icon>
            <span>数据字典</span>
          </template>
          <el-menu-item index="/dictManagement">字典管理</el-menu-item>
        </el-sub-menu>
      </el-menu>
    </div>
    <div :style="{width:(isCollapse ? 'calc(100% - 64px)' : 'calc(100% - 168px)')}">
      <!-- 右侧顶部条 -->
      <el-header style="padding-top:22px;height:10vh;background-color:#222839;">
        <!-- 折叠按钮 + 退出登录  -->
        <el-row :gutter="10">
          <el-col :span="18">
            <el-icon style="font-size:20px;color: #fff" @click="changeCollapse">
              <Expand/>
            </el-icon>
          </el-col>
          <el-col :span="6" style="position: relative;">
            <el-dropdown trigger="click" style="position:absolute;right:20px;">
              <span style="font-size:19px;font-weight: bold;">
<!--                {{user.username}}-->
                <el-icon style="color: #fff"><arrow-down/></el-icon>
              </span>
              <template #dropdown>
                <el-dropdown-menu>
                  <el-dropdown-item @click="logout">退出登录</el-dropdown-item>
                </el-dropdown-menu>
              </template>
            </el-dropdown>
          </el-col>
        </el-row>
        <!-- 面包屑导航  -->
        <!--        <el-breadcrumb separator="/" style="position:relative;top:20px;">-->
        <!--          <el-breadcrumb-item>首页</el-breadcrumb-item>-->
        <!--          <el-breadcrumb-item v-for="item in breadcrumb">{{item}}</el-breadcrumb-item>-->
        <!--        </el-breadcrumb>-->
      </el-header>
      <!-- 右侧的主题内容:也是除顶部条与面包屑之外的可变区域,可变内容在各个子页面中写! -->
      <el-main style="height:90vh;padding:0;overflow-y: auto;">
        <router-view/>
      </el-main>
    </div>
  </div>
</template>

<script setup>


//定义变量控制左侧菜单栏是否折叠
import {ref} from "vue";

const isCollapse = ref(false);
//定义修改菜单栏是否折叠的方法
const changeCollapse = () => {
  isCollapse.value = !isCollapse.value;
}

</script>